$(function () {

    var studAcc = new StudentAcc();

    studAcc.firstStart();

});

class StudentAcc {
    constructor() {

        this.account = new Account();

        this.sid = 's11';
        this.acc = {};

        this.peasonalDetail ;

        this.pwdChange = new PwdManage("id-student-layui-body-personalCenter-pwd", "id-student-body-personalCenter-pwd-form");

        this.studCardDetail = new StudCardDetail("id-student-layui-body-stud-details", "id-student-layui-body-stud-details-table");

        this.studChooseCourse = new StudChooseCourse("id-student-layui-body-stud-details", "id-student-layui-body-stud-details-choose-Course-table", "filter-stud-details-choose-Course-table");

    }

    firstStart(){

        let load = this;
        
        $.post("/Lock/GetAcc",{},function(resp){
            load.acc = resp.acc;
            load.peasonalDetail =  new PeasonalDetail("id-studnet-body-peasonal-center-details",resp.acc);
            load.sid = resp.acc.aid;
            load.start();
        })
    }

    start() {


        let load = this;
        load.account.loadAccount();

        load.peasonalDetail.start();

        $(".student-layui-body").show().children().hide();
        

        $("#id-student-layui-side-personalCenter-pwd").on('click', function () { load.loadPwd(); return false; });

        $("#id-student-layui-side-course").on('click', function () { load.loadCourse(); return false; });

        $("#id-studnet-side-peasonal-center-details").on('click',function(){load.loadPeasonal(); return false;});

        $("#id-layui-nav-rig-quit").on('click',function(){ MyUtils.quitAcc(); return false;});
    }

    loadPeasonal(){

        $("#id-student-body-peasonal-center").show().siblings().hide();
        $("#id-studnet-body-peasonal-center-details").show().siblings().hide();
        // $("#id-studnet-side-peasonal-center-details")
    }
   

    loadPwd() {

        $("#id-student-body-peasonal-center").show().siblings().hide();

        console.log("click");
        this.pwdChange.start();
    }

    loadCourse() {
        let load = this;
        $("#id-student-body-peasonal-course").show().siblings().hide();

        load.studCardDetail.start(load.sid);

        layui.element.on('tab(filter-student-layui-body-stud-details-tab)', function(data){
           
            let index = data.index; 
            if(index == 0){
                load.studCardDetail.start(load.sid);
            }else if(index == 1){
                console.log("click");
                load.studChooseCourse.start(load.sid);
            }
          });
    }
}